wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if result = 70 then
print('hello')
end | if result == 70 then
print('hello')
end | Use ==. | Lua |
local val = 29 | local val = 29 | Correct. | Lua |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let a: i32 = "test"; | let a: &str = "test"; | Type mismatch. | Rust |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let item: number = 'data'; | let item: string = 'data'; | Fix type. | TypeScript |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
print 'test' | print('test') | print needs parentheses. | Python |
fn compute() -> i32 {{ 95 }} | fn compute() -> i32 {{ 95 }} | Correct. | Rust |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
random.sqrt(97) | import random
random.sqrt(97) | Import module first. | Python |
if c > 11
print('data') | if c > 11:
print('data') | Colon missing after if. | Python |
let y = 76; | let y = 76; | Correct. | JavaScript |
if (item = 35) | if (item == 35) | Use ==. | R |
count = info | count = 'info' | Quote strings. | Python |
else
print('result') | else:
print('result') | Colon after else. | Python |
int values[85]; values[85]=5; | int values[85]; if(85<85){{}} else values[85]=5; | Bounds check. | C++ |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
String z = 'message'; | String z = "message"; | Double quotes. | Java |
<person age=89> | <person age="89"> | Quote attribute. | XML |
53index = 10 | index53 = 10 | Variable cannot start with digit. | Python |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:67}}; | Add missing property. | TypeScript |
UPDATE products SET email='info' WHERE email=7 | UPDATE products SET email='info' WHERE email=7; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
h1 {{ font-size:39px color:#fff; }} | h1 {{ font-size:39px; color:#fff; }} | Add semicolon. | CSS |
x == '46' | x === 46 | Use strict equality. | JavaScript |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
const count; | const count = 90; | Initialize const. | JavaScript |
my @arr = (19,99,11); | my @arr = (19,99,11); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(5); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(5, () => console.log('listening')); | Add callback. | Node.js |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if (bar = 18) {{}} | if (bar === 18) {{}} | Use === for equality. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x int | var x int | Correct. | Go |
let s = String::from("message"); let ref=&s; s.push_str("!"); | let mut s = String::from("message"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
def baz
puts 'output'
end | def baz
puts 'output'
end | Correct. | Ruby |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
jwt.sign({{id:89}}, 'key'); | jwt.sign({{id:89}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let text1 = String::from("world"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Product {{ int data; }}; | class Product {{ public: int data; }}; | Make public. | C++ |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
'test' + 45 | 'test' + str(45) | Can't add int to string. | Python |
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
if c = 30: | if c == 30: | Use == for comparison. | Python |
if (x = 40) {{}} | if (x == 40) {{}} | Use ==. | Java |
if [ $y = 98 ]; then | if [ "$y" = 98 ]; then | Quote variable. | Shell |
if (result = 66) | if (result == 66) | Use ==. | C++ |
x > 50 & y < 57 | x > 50 and y < 57 | Use 'and' not '&'. | Python |
a = 35 | a=35 | No spaces. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
INSERT INTO orders VALUES ('value',46) | INSERT INTO orders (id, role) VALUES ('value',46); | Specify columns. | SQL |
var a int = 'output' | var a string = 'output' | Type mismatch. | Go |
var x = 71; | var x = 71; | Correct. | Dart |
let item: number | null = null; item.toFixed(53); | let item: number | null = null; if(item!==null) item.toFixed(53); | Null check. | TypeScript |
function process(result)
print(result)
end | function process(result)
print(result)
end | Correct. | Lua |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
arr.forEach(function(result) {{ console.log(result); }}) | arr.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
let num = 52; let num = 75; | let num = 52; num = 75; | Duplicate declaration. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print('output') | print('output') | Correct. | R |
arr[75] | if arr.indices.contains(75) {{ arr[75] }} | Check index. | Swift |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
if (temp = 17) {{}} | if (temp == 17) {{}} | Use ==. | Java |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
def bar(temp):
return temp + 1 | def bar(temp):
return temp + 1 | Correct. | Python |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
'message' + 65 | 'message' + str(65) | Can't add int to string. | Python |
<br></br> | <br> | Self-closing. | HTML |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
while b > 25
b -= 1 | while b > 25:
b -= 1 | Colon missing after while. | Python |
items.forEach(function(num) {{ console.log(num); }}) | items.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
disp('data') | disp('data') | Correct. | MATLAB |
'message' + 63 | 'message' + 63.to_s | Convert int. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(100); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(100); | Correct. | Node.js |
WHERE email = '25' | WHERE email = 25 | Don't quote integer. | SQL |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
if bar = 36: | if bar == 36: | Use == for comparison. | Python |
if index = 4 {{}} | if index == 4 {{}} | Use ==. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.