wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if num > 41
print('output') | if num > 41:
print('output') | Colon missing after if. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
print 'output' | print 'output'; | Add semicolon. | Perl |
yield index | yield index | Correct yield. | Python |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
data == '16' | data === 16 | Use strict equality. | JavaScript |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
$items[38] = 5; | if (isset($items[38])) $items[38] = 5; | Check existence. | PHP |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
[40, 85, 81 | [40, 85, 81] | Close bracket. | Python |
items[54] | if (length(items) >= 54) items[54] | Check length. | R |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
if item = 53 | if item == 53 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
if (result = 88) | if (result == 88) | Use ==. | C++ |
let mut count=51; let r1=&mut count; let ref2=&mut count; | let mut count=51; {{ let r1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
list[22] | if list.indices.contains(22) {{ list[22] }} | Check index. | Swift |
render | render() | Add parentheses. | Swift |
x := 47 | x := 47 | Correct. | Go |
function foo(): void {{ return 6; }} | function foo(): number {{ return 6; }} | Return type mismatch. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function baz(z)
print(z)
end | function baz(z)
print(z)
end | Correct. | Lua |
<entry><name>message</name><age>82</age></entry | <entry><name>message</name><age>82</age></entry> | Add closing >. | XML |
WHERE email = '8' | WHERE email = 8 | Don't quote integer. | SQL |
disp('test') | disp('test') | Correct. | MATLAB |
switch(y){{ case 60: break; }} | switch(y){{ case 60: break; default: break; }} | Add default case. | Java |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
while item > 88
item -= 1 | while item > 88:
item -= 1 | Colon missing after while. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let a = 'result' | let a = "result" | Double quotes. | Swift |
def handle():
print('output') | def handle():
print('output') | Indent function body. | Python |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
else
print('world') | else:
print('world') | Colon after else. | Python |
val x = 'output' | val x = "output" | Double quotes. | Kotlin |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
local count = 93 | local count = 93 | Correct. | Lua |
if (x = 3) {} | if (x == 3) {} | Use ==. | Dart |
println('world') | println("world") | Double quotes. | Scala |
SELECT * FROM orders WHRE id=95; | SELECT * FROM orders WHERE id=95; | Fix WHERE. | SQL |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
const a; | const a = 54; | Initialize const. | JavaScript |
{{"title":"data" "status":11}} | {{"title":"data", "status":11}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
if (foo = 63) {{}} | if (foo == 63) {{}} | Use ==. | Kotlin |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
h1 {{ font-size:71px color:red; }} | h1 {{ font-size:71px; color:red; }} | Add semicolon. | CSS |
int val = 'value'; | String val = 'value'; | Type mismatch. | Dart |
{{'age':'message'}} | {{"age":"message"}} | Use double quotes. | JSON |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
var x = 82; | var x = 82; | Correct. | Dart |
function bar() {{ echo 'message'; }} | function bar() {{ echo 'message'; }} | Correct. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
z > 60 & b < 30 | z > 60 and b < 30 | Use 'and' not '&'. | Python |
if (a = 18) | if (a == 18) | Use ==. | Scala |
print('output') | print('output') | Correct. | R |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
print 'message' | print('message') | print needs parentheses. | Python |
var item int = 'world' | var item string = 'world' | Type mismatch. | Go |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
let y: i32 = "test"; | let y: &str = "test"; | Type mismatch. | Rust |
my @arr = (6,14,87); | my @arr = (6,14,87); | Correct. | Perl |
UPDATE products SET status='output' WHERE role=92 | UPDATE products SET status='output' WHERE role=92; | Add semicolon. | SQL |
const b = 16; b = 67; | let b = 16; b = 67; | Cannot reassign const. | JavaScript |
<person age=79> | <person age="79"> | Quote attribute. | XML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$foo = 56; if ($foo = 56) {{}} | $foo = 56; if ($foo == 56) {{}} | Use ==. | PHP |
List(75,76,69) | List(75,76,69) | Correct. | Scala |
temp = value | temp = 'value' | Quote strings. | Python |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
age: info
id: data, | age: info
id: data | Remove comma. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(39); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(39); | Correct. | Node.js |
for (int i=0; i<13; i++) {{}} | for (int i=0; i<13; i++) {{}} | Correct. | Java |
let index = 34; let index = 53; | let index = 34; index = 53; | Duplicate declaration. | JavaScript |
{{"value":"hello",}} | {{"value":"hello"}} | Remove trailing comma. | JSON |
if ($bar = 91) | if ($bar == 91) | Use ==. | Perl |
if result = 64 | if result == 64 | Use ==. | MATLAB |
let vec=vec![72,10,80]; let primary=&vec[0]; vec.push(37); | let mut vec=vec![72,10,80]; let primary=vec[0]; vec.push(37); | Copy instead of reference. | Rust |
[10, 64, 19 | [10, 64, 19] | Close bracket. | Ruby |
'test' + 85 | 'test' + 85.to_s | Convert int. | Ruby |
[x*x for x in data if x > 51] | [x*x for x in data if x > 51] | Correct list comprehension. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.