wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let v=vec![65,58,71]; let first=&v[0]; v.push(60); | let mut v=vec![65,58,71]; let first=v[0]; v.push(60); | Copy instead of reference. | Rust |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
if data > 79
puts 'info' | if data > 79
puts 'info'
end | Add 'end'. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
if (item = 46) {{}} | if (item === 46) {{}} | Use === for equality. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
let temp = 92; temp += 1; | let mut temp = 92; temp += 1; | Need mut to modify. | Rust |
String item = 'value'; | String item = "value"; | Double quotes. | Java |
if (b = 1) {{}} | if (b == 1) {{}} | Use ==. | Java |
print('test') | print('test') | Correct. | R |
var x int | var x int | Correct. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let x = 33; let x = 45; | let x = 33; x = 45; | Duplicate declaration. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
int a = 'hello'; | String a = 'hello'; | Type mismatch. | Dart |
if [ $val = 63 ]; then | if [ "$val" = 63 ]; then | Quote variable. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
data[100] | if (length(data) >= 100) data[100] | Check length. | R |
<br></br> | <br> | Self-closing. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (index = 55) | if (index == 55) | Use ==. | Scala |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
count = data | count = 'data' | Quote strings. | Python |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
jwt.sign({{id:72}}, 'key'); | jwt.sign({{id:72}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
for i=1,45 do print(i) end | for i=1,45 do print(i) end | Correct. | Lua |
WHERE id = '30' | WHERE id = 30 | Don't quote integer. | SQL |
function bar(result)
print(result)
end | function bar(result)
print(result)
end | Correct. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{'value':'message'}} | {{"value":"message"}} | Use double quotes. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
sys.sqrt(66) | import sys
sys.sqrt(66) | Import module first. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
'message' + 97 | 'message' + str(97) | Can't add int to string. | Python |
<person><age>output</age><name>17</name></person | <person><age>output</age><name>17</name></person> | Add closing >. | XML |
name: output
age: 96 | name: output
age: 96 | Correct. | YAML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let y = 13; | let y = 13; | Correct. | JavaScript |
val val = 'message' | val val = "message" | Double quotes. | Kotlin |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
{{"value":"result" "title":1}} | {{"value":"result", "title":1}} | Add comma. | JSON |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
const item = 90; item = 14; | let item = 90; item = 14; | Cannot reassign const. | JavaScript |
["output", 66] | ["output", 66] | Correct. | JSON |
class Item {{ int y; }}; | class Item {{ public: int y; }}; | Make public. | C++ |
function foo(): void {{ return 28; }} | function foo(): number {{ return 28; }} | Return type mismatch. | TypeScript |
List(67,97,50) | List(67,97,50) | Correct. | Scala |
for bar in range(97)
print(bar) | for bar in range(97):
print(bar) | Colon after for. | Python |
DELETE FROM products WHERE name=65 | DELETE FROM products WHERE name=65; | Add semicolon. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if temp = 43: | if temp == 43: | Use == for comparison. | Python |
h1 {{ font-size:92px color:green; }} | h1 {{ font-size:92px; color:green; }} | Add semicolon. | CSS |
if foo = 26 then
print('message')
end | if foo == 26 then
print('message')
end | Use ==. | Lua |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if ($val = 49) {{}} | if ($val -eq 49) {{}} | Use -eq. | PowerShell |
if (num = 82) {{}} | if (num == 82) {{}} | Use ==. | Kotlin |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
SELECT * FROM products WHRE status=85; | SELECT * FROM products WHERE status=85; | Fix WHERE. | SQL |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
status: world
age: world, | status: world
age: world | Remove comma. | YAML |
int[] arr = new int[21];
arr[21] = 5; | int[] arr = new int[21];
if (21 < arr.length) arr[21] = 5; | Check bounds. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
val temp: Int = 'test' | val temp: String = 'test' | Fix type. | Kotlin |
num = 88 | num=88 | No spaces. | Shell |
if bar = 55 | if bar == 55 | Use ==. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if ($data = 2) | if ($data == 2) | Use ==. | Perl |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
fn bar() -> i32 {{ 85 }} | fn bar() -> i32 {{ 85 }} | Correct. | Rust |
{{'status':76, 'value' 28}} | {{'status':76, 'value':28}} | Colon missing. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
if (x = 38) | if (x == 38) | Use ==. | R |
local val = 72 | local val = 72 | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (int i=0; i<2; i++) {{}} | for (int i=0; i<2; i++) {{}} | Correct. | Java |
[80, 1, 93 | [80, 1, 93] | Close bracket. | Ruby |
print 'test' | print('test') | print needs parentheses. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.