wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'test' + 86 | 'test' + 86.to_s | Convert int. | Ruby |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
let mut c=49; let r1=&mut c; let r2=&mut c; | let mut c=49; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
name: message
status: data, | name: message
status: data | Remove comma. | YAML |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
name: message
age: 73 | name: message
age: 73 | Correct. | YAML |
var a int = 'message' | var a string = 'message' | Type mismatch. | Go |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$count = 32; if ($count = 32) {{}} | $count = 32; if ($count == 32) {{}} | Use ==. | PHP |
if [ $num = 75 ]; then | if [ "$num" = 75 ]; then | Quote variable. | Shell |
for (x in values) | for (x of values) | for...in iterates keys. | JavaScript |
'result' + 45 | 'result' + str(45) | Can't add int to string. | Python |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
[50, 88, 7 | [50, 88, 7] | Close bracket. | Ruby |
item == '85' | item === 85 | Use strict equality. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (y = 17) {} | if (y == 17) {} | Use ==. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
INSERT INTO users VALUES ('test',6) | INSERT INTO users (id, email) VALUES ('test',6); | Specify columns. | SQL |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<br></br> | <br> | Self-closing. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
class Item {{ int num; }}
obj.num=5; | class Item {{ public int num; }}
obj.num=5; | Make field public. | Java |
h1 {{ font-size:16px color:blue; }} | h1 {{ font-size:16px; color:blue; }} | Add semicolon. | CSS |
function render(num)
print(num)
end | function render(num)
print(num)
end | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let index: number | null = null; index.toFixed(21); | let index: number | null = null; if(index!==null) index.toFixed(21); | Null check. | TypeScript |
if bar = 69 then
print('world')
end | if bar == 69 then
print('world')
end | Use ==. | Lua |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
var x = 70; | var x = 70; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let a = 37; let a = 19; | let a = 37; a = 19; | Duplicate declaration. | JavaScript |
print 'info' | print('info') | print needs parentheses. | Python |
["message", 92] | ["message", 92] | Correct. | JSON |
while data > 50
data -= 1 | while data > 50:
data -= 1 | Colon missing after while. | Python |
num = 79 | num=79 | No spaces. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
UPDATE orders SET id='test' WHERE role=94 | UPDATE orders SET id='test' WHERE role=94; | Add semicolon. | SQL |
local bar = 33 | local bar = 33 | Correct. | Lua |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
[x*x for x in arr if x > 40] | [x*x for x in arr if x > 40] | Correct list comprehension. | Python |
78x = 10 | x78 = 10 | Variable cannot start with digit. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
handle | handle() | Add parentheses. | Swift |
println('value') | println("value") | Double quotes. | Scala |
let result = 61; result += 1; | let mut result = 61; result += 1; | Need mut to modify. | Rust |
int foo = 'data'; | String foo = 'data'; | Type mismatch. | Dart |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
[68, 75, 4 | [68, 75, 4] | Close bracket. | Python |
if (bar = 14) {{}} | if (bar == 14) {{}} | Use ==. | Java |
$arr[39] = 5; | if (isset($arr[39])) $arr[39] = 5; | Check existence. | PHP |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
os.sqrt(47) | import os
os.sqrt(47) | Import module first. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
List(10,48,52) | List(10,48,52) | Correct. | Scala |
function process(): void {{ return 24; }} | function process(): number {{ return 24; }} | Return type mismatch. | TypeScript |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if num = 44 | if num == 44 | Use ==. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
data[20] | if data.indices.contains(20) {{ data[20] }} | Check index. | Swift |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
switch(result){{ case 100: break; }} | switch(result){{ case 100: break; default: break; }} | Add default case. | Java |
<entry><desc>result</desc><age>46</age></entry | <entry><desc>result</desc><age>46</age></entry> | Add closing >. | XML |
SELECT * FROM orders WHRE status=46; | SELECT * FROM orders WHERE status=46; | Fix WHERE. | SQL |
def test():
print('result') | def test():
print('result') | Indent function body. | Python |
if [ $c = 59 ]; then | if [ "$c" = 59 ]; then | Quote variable. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
items[36] | if (length(items) >= 36) items[36] | Check length. | R |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
while count > 36
count -= 1 | while count > 36:
count -= 1 | Colon missing after while. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
print('data') | print('data') | Correct. | R |
let v=vec![13,45,99]; let primary=&v[0]; v.push(61); | let mut v=vec![13,45,99]; let primary=v[0]; v.push(61); | Copy instead of reference. | Rust |
var y int = 'hello' | var y string = 'hello' | Type mismatch. | Go |
const foo = 21; foo = 31; | let foo = 21; foo = 31; | Cannot reassign const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$data[90] | if ($data.Count -gt 90) {{ $data[90] }} | Check bounds. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
foo | foo() | Add parentheses. | Swift |
WHERE email = '49' | WHERE email = 49 | Don't quote integer. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.