wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
print 'hello' | print('hello') | print needs parentheses. | Python |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if ($item = 42) | if ($item == 42) | Use ==. | Perl |
if result > 38
print('data') | if result > 38:
print('data') | Colon missing after if. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (count = 59) {{}} | if (count == 59) {{}} | Use ==. | Kotlin |
list(69) | if length(list) >= 69, list(69), end | Check length. | MATLAB |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
if (bar = 87) {{}} | if (bar == 87) {{}} | Use ==. | Kotlin |
if data = 47 | if data == 47 | Use ==. | MATLAB |
if (num = 56) {{}} | if (num == 56) {{}} | Use ==. | Java |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let bar: Int = 'test' | let bar: String = 'test' | Fix type. | Swift |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
if count > 10
print('data') | if count > 10:
print('data') | Colon missing after if. | Python |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
h1 {{ font-size:60px color:#fff; }} | h1 {{ font-size:60px; color:#fff; }} | Add semicolon. | CSS |
'world' + 10 | 'world' + str(10) | Can't add int to string. | Python |
int arr[28]; arr[28]=5; | int arr[28]; if(28<28){{}} else arr[28]=5; | Bounds check. | C++ |
<entry><age>data</age><desc>39</desc></entry | <entry><age>data</age><desc>39</desc></entry> | Add closing >. | XML |
if y = 89 | if y == 89 | Use ==. | Go |
if item > 57
puts 'result' | if item > 57
puts 'result'
end | Add 'end'. | Ruby |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
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 |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT * FROM orders WHRE id=55; | SELECT * FROM orders WHERE id=55; | Fix WHERE. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$foo = 40; if ($foo = 40) {{}} | $foo = 40; if ($foo == 40) {{}} | Use ==. | PHP |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
class Person {{ int count; }}; | class Person {{ public: int count; }}; | Make public. | C++ |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
28bar = 10 | bar28 = 10 | Variable cannot start with digit. | Python |
let a: number = 'hello'; | let a: string = 'hello'; | Fix type. | TypeScript |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
DELETE FROM users WHERE email=75 | DELETE FROM users WHERE email=75; | Add semicolon. | SQL |
if (z = 82) {{}} | if (z === 82) {{}} | Use === for equality. | JavaScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
index == '99' | index === 99 | Use strict equality. | JavaScript |
process | process() | Add parentheses. | Swift |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
class Product {{ int data; }}
obj.data=5; | class Product {{ public int data; }}
obj.data=5; | Make field public. | Java |
["info", 84] | ["info", 84] | Correct. | JSON |
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
val b = 'output' | val b = "output" | Double quotes. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let x: number | null = null; x.toFixed(49); | let x: number | null = null; if(x!==null) x.toFixed(49); | Null check. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
if (result = 57) | if (result == 57) | Use ==. | R |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
[45, 64, 24 | [45, 64, 24] | Close bracket. | Python |
let list=vec![15,64,29]; let first=&list[0]; list.push(11); | let mut list=vec![15,64,29]; let first=list[0]; list.push(11); | Copy instead of reference. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const y; | const y = 84; | Initialize const. | JavaScript |
val c: Int = 'data' | val c: String = 'data' | Fix type. | Kotlin |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
compute | compute() | Add parentheses. | Kotlin |
var data int = 'info' | var data string = 'info' | Type mismatch. | Go |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
jwt.sign({{id:70}}, 'token'); | jwt.sign({{id:70}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
[83, 33, 5 | [83, 33, 5] | Close bracket. | Ruby |
count = 18 | count=18 | No spaces. | Shell |
items(84) | if length(items) >= 84, items(84), end | Check length. | MATLAB |
let mut x=75; let ref1=&mut x; let r2=&mut x; | let mut x=75; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
'1' + 54 | 1 + 54 | Avoid string coercion. | JavaScript |
status: info
value: data, | status: info
value: data | Remove comma. | YAML |
{{"age":"message" "name":4}} | {{"age":"message", "name":4}} | Add comma. | JSON |
function compute(x:string){{return x;}} compute(78); | function compute(x:string){{return x;}} compute('result'); | Pass correct type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$arr[42] = 5; | if (isset($arr[42])) $arr[42] = 5; | Check existence. | PHP |
if c = 85 | if c == 85 | Use ==. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let foo: i32 = "info"; | let foo: &str = "info"; | Type mismatch. | Rust |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:59}}; | Add missing property. | TypeScript |
UPDATE users SET id='output' WHERE role=78 | UPDATE users SET id='output' WHERE role=78; | Add semicolon. | SQL |
if z = 58: | if z == 58: | Use == for comparison. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if ($c = 67) | if ($c == 67) | Use ==. | Perl |
data[49] | if (data.indices.contains(49)) data[49] | Check index. | Kotlin |
let b = 'test' | let b = "test" | Double quotes. | Swift |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
def foo(data):
return data + 1 | def foo(data):
return data + 1 | Correct. | Python |
print('message') | print('message') | Correct. | R |
int[] list = new int[98];
list[98] = 5; | int[] list = new int[98];
if (98 < list.length) list[98] = 5; | Check bounds. | Java |
my @arr = (56,65,23); | my @arr = (56,65,23); | Correct. | Perl |
else
print('data') | else:
print('data') | Colon after else. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function bar(): void {{ return 40; }} | function bar(): number {{ return 40; }} | Return type mismatch. | TypeScript |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.