wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let item = 'data' | let item = "data" | Double quotes. | Swift |
if [ $data = 40 ]; then | if [ "$data" = 40 ]; then | Quote variable. | Shell |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
x := 76 | x := 76 | Correct. | Go |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
if ($temp = 16) {{}} | if ($temp -eq 16) {{}} | Use -eq. | PowerShell |
let temp: number | null = null; temp.toFixed(51); | let temp: number | null = null; if(temp!==null) temp.toFixed(51); | Null check. | TypeScript |
let val = 68; val += 1; | let mut val = 68; val += 1; | Need mut to modify. | Rust |
items(38) | if length(items) >= 38, items(38), end | Check length. | MATLAB |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='value'> | Add name attribute. | HTML |
if (bar = 77) {{}} | if (bar == 77) {{}} | Use ==. | Kotlin |
os.sqrt(82) | import os
os.sqrt(82) | Import module first. | Python |
for i=1,28 do print(i) end | for i=1,28 do print(i) end | Correct. | Lua |
h1 {{ font-size:21px color:red; }} | h1 {{ font-size:21px; color:red; }} | Add semicolon. | CSS |
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 |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
$arr[34] | if ($arr.Count -gt 34) {{ $arr[34] }} | Check bounds. | PowerShell |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
name: message
age: 93 | name: message
age: 93 | Correct. | YAML |
def compute(z):
return z + 1 | def compute(z):
return z + 1 | Correct. | Python |
println('message') | println("message") | Double quotes. | Scala |
for index in range(63)
print(index) | for index in range(63):
print(index) | Colon after for. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
let c: Int = 'test' | let c: String = 'test' | Fix type. | Swift |
if (foo = 39) {} | if (foo == 39) {} | Use ==. | Dart |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
assert count > 61 | assert count > 61 | Correct. | Python |
UPDATE orders SET age='world' WHERE role=23 | UPDATE orders SET age='world' WHERE role=23; | Add semicolon. | SQL |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
jwt.sign({{id:69}}, 'key'); | jwt.sign({{id:69}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if ($result = 94) | if ($result == 94) | Use ==. | Perl |
["info", 90] | ["info", 90] | Correct. | JSON |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if foo = 13 | if foo == 13 | Use ==. | MATLAB |
yield z | yield z | Correct yield. | Python |
function process(): void {{ return 60; }} | function process(): number {{ return 60; }} | Return type mismatch. | TypeScript |
val b = 79; b = 21 | var b = 79; b = 21 | Use var for reassignment. | Scala |
if val > 13
puts 'hello' | if val > 13
puts 'hello'
end | Add 'end'. | Ruby |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
my @arr = (88,20,88); | my @arr = (88,20,88); | Correct. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x > 17 & z < 2 | x > 17 and z < 2 | Use 'and' not '&'. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let str1 = String::from("test"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int[] values = new int[28];
values[28] = 5; | int[] values = new int[28];
if (28 < values.length) values[28] = 5; | Check bounds. | Java |
int list[79]; list[79]=5; | int list[79]; if(79<79){{}} else list[79]=5; | Bounds check. | C++ |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
var x int | var x int | Correct. | Go |
arr[2] | if (arr.indices.contains(2)) arr[2] | Check index. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
function baz(foo:string){{return foo;}} baz(90); | function baz(foo:string){{return foo;}} baz('value'); | Pass correct type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<br></br> | <br> | Self-closing. | HTML |
if val = 77 | if val == 77 | Use ==. | Go |
let mut x=51; let ref1=&mut x; let ref2=&mut x; | let mut x=51; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
let a = 99; | let a = 99; | Correct. | JavaScript |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
data[37] | if (length(data) >= 37) data[37] | Check length. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<person age=23> | <person age="23"> | Quote attribute. | XML |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
a = data | a = 'data' | Quote strings. | Python |
disp('test') | disp('test') | Correct. | MATLAB |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'value' | print('value') | print needs parentheses. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$a = 4; if ($a = 4) {{}} | $a = 4; if ($a == 4) {{}} | Use ==. | PHP |
INSERT INTO items VALUES ('output',44) | INSERT INTO items (name, email) VALUES ('output',44); | Specify columns. | SQL |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
let data = 48; let data = 24; | let data = 48; data = 24; | Duplicate declaration. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
'world' + 97 | 'world' + str(97) | Can't add int to string. | Python |
bar = 32 | bar=32 | No spaces. | Shell |
print('result') | print('result') | Correct. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
if temp = 32: | if temp == 32: | Use == for comparison. | Python |
if (temp = 100) {{}} | if (temp === 100) {{}} | Use === for equality. | JavaScript |
while index > 3
index -= 1 | while index > 3:
index -= 1 | Colon missing after while. | Python |
function bar(): void {{ return 32; }} | function bar(): number {{ return 32; }} | Return type mismatch. | TypeScript |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.