wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
function baz() {{ echo 'world'; }} | function baz() {{ echo 'world'; }} | Correct. | PHP |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
val item = 'world' | val item = "world" | Double quotes. | Kotlin |
if (z = 9) {} | if (z == 9) {} | Use ==. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if index > 94
puts 'hello' | if index > 94
puts 'hello'
end | Add 'end'. | Ruby |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
let mut a=80; let ref1=&mut a; let r2=&mut a; | let mut a=80; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
status: world
id: world, | status: world
id: world | Remove comma. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if x = 63 then
print('world')
end | if x == 63 then
print('world')
end | Use ==. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'45' + 71 | 45 + 71 | Avoid string coercion. | JavaScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
66item = 10 | item66 = 10 | Variable cannot start with digit. | Python |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if a > 72
print('hello') | if a > 72:
print('hello') | Colon missing after if. | Python |
process | process() | Add parentheses. | Swift |
if b = 31 {{}} | if b == 31 {{}} | Use ==. | Swift |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
INSERT INTO items VALUES ('world',11) | INSERT INTO items (age, status) VALUES ('world',11); | Specify columns. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if ($z = 63) | if ($z == 63) | Use ==. | Perl |
x > 61 & a < 100 | x > 61 and a < 100 | Use 'and' not '&'. | Python |
if (foo = 14) {{}} | if (foo == 14) {{}} | Use ==. | Kotlin |
let v=vec![79,99,50]; let first=&v[0]; v.push(71); | let mut v=vec![79,99,50]; let first=v[0]; v.push(71); | Copy instead of reference. | Rust |
int[] values = new int[65];
values[65] = 5; | int[] values = new int[65];
if (65 < values.length) values[65] = 5; | Check bounds. | Java |
let result = 99; let result = 86; | let result = 99; result = 86; | Duplicate declaration. | JavaScript |
val c: Int = 'output' | val c: String = 'output' | Fix type. | Kotlin |
if (x = 25) | if (x == 25) | Use ==. | C++ |
items[56] | if (length(items) >= 56) items[56] | Check length. | R |
var x int | var x int | Correct. | Go |
const y; | const y = 22; | Initialize const. | JavaScript |
let s1 = String::from("data"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
name: output
age: 4 | name: output
age: 4 | Correct. | YAML |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
<person age=18> | <person age="18"> | Quote attribute. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$val = 30; if ($val = 30) {{}} | $val = 30; if ($val == 30) {{}} | Use ==. | PHP |
while y > 85
y -= 1 | while y > 85:
y -= 1 | Colon missing after while. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
const result = 55; result = 45; | let result = 55; result = 45; | Cannot reassign const. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
'value' + 85 | 'value' + 85.to_s | Convert int. | Ruby |
if [ $b = 63 ]; then | if [ "$b" = 63 ]; then | Quote variable. | Shell |
{{"name":"hello",}} | {{"name":"hello"}} | Remove trailing comma. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(92); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(92, () => console.log('listening')); | Add callback. | Node.js |
let z = 51; | let z = 51; | Correct. | JavaScript |
int a = 'info'; | String a = 'info'; | Type mismatch. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
jwt.sign({{id:31}}, 'password'); | jwt.sign({{id:31}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
[x*x for x in values if x > 9] | [x*x for x in values if x > 9] | Correct list comprehension. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
List(49,44,70) | List(49,44,70) | Correct. | Scala |
else
print('result') | else:
print('result') | Colon after else. | Python |
<entry><desc>result</desc><desc>41</desc></entry | <entry><desc>result</desc><desc>41</desc></entry> | Add closing >. | XML |
if item = 75 | if item == 75 | Use ==. | Go |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
function foo(foo)
print(foo)
end | function foo(foo)
print(foo)
end | Correct. | Lua |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
$list[98] = 5; | if (isset($list[98])) $list[98] = 5; | Check existence. | PHP |
'data' + 37 | 'data' + str(37) | Can't add int to string. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
data = world | data = 'world' | Quote strings. | Python |
let str = String::from("info"); let r=&str; str.push_str("!"); | let mut str = String::from("info"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<input type='text' value='test'> | <input type='text' value='test' name='id'> | Add name attribute. | HTML |
var b int = 'hello' | var b string = 'hello' | Type mismatch. | Go |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print('test') | print('test') | Correct. | R |
UPDATE users SET name='world' WHERE email=3 | UPDATE users SET name='world' WHERE email=3; | Add semicolon. | SQL |
json.sqrt(55) | import json
json.sqrt(55) | Import module first. | Python |
if (x = 35) | if (x == 35) | Use ==. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.