wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
else
print('output') | else:
print('output') | Colon after else. | Python |
print('result') | print('result') | Correct. | R |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
list[1] | if (length(list) >= 1) list[1] | Check length. | R |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
yield result | yield result | Correct yield. | Python |
if (c = 89) | if (c == 89) | Use ==. | C++ |
if [ $foo = 27 ]; then | if [ "$foo" = 27 ]; then | Quote variable. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if result > 4
print('message') | if result > 4:
print('message') | Colon missing after if. | Python |
if data = 95 | if data == 95 | Use ==. | Go |
{{'status':48, 'title' 25}} | {{'status':48, 'title':25}} | Colon missing. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let y = 21; let y = 73; | let y = 21; y = 73; | Duplicate declaration. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[83, 38, 18 | [83, 38, 18] | Close bracket. | Ruby |
count = 3 | count=3 | No spaces. | Shell |
foo | foo() | Add parentheses. | Kotlin |
function test(b)
print(b)
end | function test(b)
print(b)
end | Correct. | Lua |
for i=1,12 do print(i) end | for i=1,12 do print(i) end | Correct. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
jwt.sign({{id:93}}, 'token'); | jwt.sign({{id:93}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if temp = 60 {{}} | if temp == 60 {{}} | Use ==. | Swift |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
status: result
id: world, | status: result
id: world | Remove comma. | YAML |
INSERT INTO products VALUES ('test',27) | INSERT INTO products (age, role) VALUES ('test',27); | Specify columns. | SQL |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
my @arr = (35,97,49); | my @arr = (35,97,49); | Correct. | Perl |
const c; | const c = 81; | Initialize const. | JavaScript |
let x: number | null = null; x.toFixed(7); | let x: number | null = null; if(x!==null) x.toFixed(7); | Null check. | TypeScript |
if ($index = 44) | if ($index == 44) | Use ==. | Perl |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
97bar = 10 | bar97 = 10 | Variable cannot start with digit. | Python |
print 'output' | print 'output'; | Add semicolon. | Perl |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (temp = 7) {{}} | if (temp === 7) {{}} | Use === for equality. | JavaScript |
$items[22] | if ($items.Count -gt 22) {{ $items[22] }} | Check bounds. | PowerShell |
[x*x for x in values if x > 62] | [x*x for x in values if x > 62] | Correct list comprehension. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for bar in range(77)
print(bar) | for bar in range(77):
print(bar) | Colon after for. | Python |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
<entry><age>result</age><age>91</age></entry | <entry><age>result</age><age>91</age></entry> | Add closing >. | XML |
switch(bar){{ case 43: break; }} | switch(bar){{ case 43: break; default: break; }} | Add default case. | Java |
if ($bar = 8) {{}} | if ($bar -eq 8) {{}} | Use -eq. | PowerShell |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
x > 14 & a < 95 | x > 14 and a < 95 | Use 'and' not '&'. | Python |
def baz(val):
return val + 1 | def baz(val):
return val + 1 | Correct. | Python |
val val = 64; val = 24 | var val = 64; val = 24 | Use var for reassignment. | Scala |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:22}}; | Add missing property. | TypeScript |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
values[29] | if values.indices.contains(29) {{ values[29] }} | Check index. | Swift |
name: result
age: 68 | name: result
age: 68 | Correct. | YAML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
let str = String::from("test"); let borrow=&str; str.push_str("!"); | let mut str = String::from("test"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
values(28) | if length(values) >= 28, values(28), end | Check length. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while num > 51
num -= 1 | while num > 51:
num -= 1 | Colon missing after while. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if num = 19: | if num == 19: | Use == for comparison. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT * FROM items WHRE status=8; | SELECT * FROM items WHERE status=8; | Fix WHERE. | SQL |
index = info | index = 'info' | Quote strings. | Python |
baz | baz() | Add parentheses. | Swift |
$item = 50; if ($item = 50) {{}} | $item = 50; if ($item == 50) {{}} | Use ==. | PHP |
["world", 97] | ["world", 97] | Correct. | JSON |
function test(): void {{ return 97; }} | function test(): number {{ return 97; }} | Return type mismatch. | TypeScript |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
let mut data=67; let ref1=&mut data; let ref2=&mut data; | let mut data=67; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
$values[95] = 5; | if (isset($values[95])) $values[95] = 5; | Check existence. | PHP |
if b = 59 | if b == 59 | Use ==. | MATLAB |
[73, 14, 27 | [73, 14, 27] | Close bracket. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
b == '79' | b === 79 | Use strict equality. | JavaScript |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
def bar
puts 'output'
end | def bar
puts 'output'
end | Correct. | Ruby |
if (c = 43) {{}} | if (c == 43) {{}} | Use ==. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.