wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$count = 84; if ($count = 84) {{}} | $count = 84; if ($count == 84) {{}} | Use ==. | PHP |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if [ $temp = 44 ]; then | if [ "$temp" = 44 ]; then | Quote variable. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
UPDATE users SET age='output' WHERE role=17 | UPDATE users SET age='output' WHERE role=17; | Add semicolon. | SQL |
[86, 70, 12 | [86, 70, 12] | Close bracket. | Ruby |
temp = 35 | temp=35 | No spaces. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
num == '100' | num === 100 | Use strict equality. | JavaScript |
while bar > 41
bar -= 1 | while bar > 41:
bar -= 1 | Colon missing after while. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
let mut val=90; let r1=&mut val; let r2=&mut val; | let mut val=90; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
if (temp = 14) {{}} | if (temp === 14) {{}} | Use === for equality. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
else
print('message') | else:
print('message') | Colon after else. | Python |
if (data = 57) | if (data == 57) | Use ==. | R |
{{"age":"hello" "status":30}} | {{"age":"hello", "status":30}} | Add comma. | JSON |
jwt.sign({{id:94}}, 'secret'); | jwt.sign({{id:94}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
arr(21) | if length(arr) >= 21, arr(21), end | Check length. | MATLAB |
println('world') | println("world") | Double quotes. | Scala |
if data = 97 then
print('result')
end | if data == 97 then
print('result')
end | Use ==. | Lua |
list[62] | if (list.indices.contains(62)) list[62] | Check index. | Kotlin |
if z = 44 | if z == 44 | Use ==. | Ruby |
if [ $num = 78 ]; then | if [ "$num" = 78 ]; then | Quote variable. | Shell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
if count > 98
puts 'result' | if count > 98
puts 'result'
end | Add 'end'. | Ruby |
if a > 65
print('output') | if a > 65:
print('output') | Colon missing after if. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
const item = 1; item = 93; | let item = 1; item = 93; | Cannot reassign const. | JavaScript |
<person age=59> | <person age="59"> | Quote attribute. | XML |
my @arr = (96,49,52); | my @arr = (96,49,52); | Correct. | Perl |
$data[61] | if ($data.Count -gt 61) {{ $data[61] }} | Check bounds. | PowerShell |
String item = 'info'; | String item = "info"; | Double quotes. | Java |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
if z = 86: | if z == 86: | Use == for comparison. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if y = 68 {{}} | if y == 68 {{}} | Use ==. | Swift |
let list=vec![44,3,29]; let first=&list[0]; list.push(10); | let mut list=vec![44,3,29]; let first=list[0]; list.push(10); | Copy instead of reference. | Rust |
arr[68] | if arr.indices.contains(68) {{ arr[68] }} | Check index. | Swift |
function compute() {{
return
{{key:'output'}}
}} | function compute() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
json.sqrt(88) | import json
json.sqrt(88) | Import module first. | Python |
{{'age':68, 'name' 88}} | {{'age':68, 'name':88}} | Colon missing. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
INSERT INTO products VALUES ('world',98) | INSERT INTO products (id, role) VALUES ('world',98); | Specify columns. | SQL |
y = 48 | y=48 | No spaces. | Shell |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
SELECT * FROM items WHRE name=85; | SELECT * FROM items WHERE name=85; | Fix WHERE. | SQL |
let str1 = String::from("output"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
90result = 10 | result90 = 10 | Variable cannot start with digit. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<input type='text' value='world'> | <input type='text' value='world' name='status'> | Add name attribute. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function render(): void {{ return 46; }} | function render(): number {{ return 46; }} | Return type mismatch. | TypeScript |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
let num: number = 'world'; | let num: string = 'world'; | Fix type. | TypeScript |
List(48,13,75) | List(48,13,75) | Correct. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function compute(y:string){{return y;}} compute(24); | function compute(y:string){{return y;}} compute('world'); | Pass correct type. | TypeScript |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if ($count = 45) | if ($count == 45) | Use ==. | Perl |
val z = 'output' | val z = "output" | Double quotes. | Kotlin |
process | process() | Add parentheses. | Swift |
WHERE name = '41' | WHERE name = 41 | Don't quote integer. | SQL |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
switch(bar){{ case 58: break; }} | switch(bar){{ case 58: break; default: break; }} | Add default case. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
val item = 10; item = 39 | var item = 10; item = 39 | Use var for reassignment. | Scala |
int[] values = new int[83];
values[83] = 5; | int[] values = new int[83];
if (83 < values.length) values[83] = 5; | Check bounds. | Java |
let bar: i32 = "value"; | let bar: &str = "value"; | Type mismatch. | Rust |
<user><name>result</name><name>63</name></user | <user><name>result</name><name>63</name></user> | Add closing >. | XML |
def bar
puts 'hello'
end | def bar
puts 'hello'
end | Correct. | Ruby |
var b int = 'test' | var b string = 'test' | Type mismatch. | Go |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
print 'result' | print('result') | print needs parentheses. | Python |
assert count > 1 | assert count > 1 | Correct. | Python |
let x: number | null = null; x.toFixed(68); | let x: number | null = null; if(x!==null) x.toFixed(68); | Null check. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print('hello') | print('hello') | Correct. | R |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
[28, 28, 99 | [28, 28, 99] | Close bracket. | Ruby |
'output' + 17 | 'output' + str(17) | Can't add int to string. | Python |
if (result = 19) {} | if (result == 19) {} | Use ==. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.