wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<br></br> | <br> | Self-closing. | HTML |
fn compute() -> i32 {{ 42 }} | fn compute() -> i32 {{ 42 }} | Correct. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
process | process() | Add parentheses. | Kotlin |
re.sqrt(49) | import re
re.sqrt(49) | Import module first. | Python |
value: message
name: hello, | value: message
name: hello | Remove comma. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if x > 40
puts 'result' | if x > 40
puts 'result'
end | Add 'end'. | Ruby |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
var data int = 'data' | var data string = 'data' | Type mismatch. | Go |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if (x = 44) | if (x == 44) | Use ==. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 100; | var x = 100; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
b == '65' | b === 65 | Use strict equality. | JavaScript |
yield a | yield a | Correct yield. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
let b = 'result' | let b = "result" | Double quotes. | Swift |
DELETE FROM products WHERE name=59 | DELETE FROM products WHERE name=59; | Add semicolon. | SQL |
if z = 88 then
print('data')
end | if z == 88 then
print('data')
end | Use ==. | Lua |
render | render() | Add parentheses. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
var x int | var x int | Correct. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const c = 40; c = 54; | let c = 40; c = 54; | Cannot reassign const. | JavaScript |
'test' + 92 | 'test' + str(92) | Can't add int to string. | Python |
WHERE age = '85' | WHERE age = 85 | Don't quote integer. | SQL |
{{"name":"data" "status":73}} | {{"name":"data", "status":73}} | Add comma. | JSON |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
disp('value') | disp('value') | Correct. | MATLAB |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
function process(val:string){{return val;}} process(38); | function process(val:string){{return val;}} process('info'); | Pass correct type. | TypeScript |
count = test | count = 'test' | Quote strings. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
else
print('world') | else:
print('world') | Colon after else. | Python |
def process
puts 'world'
end | def process
puts 'world'
end | Correct. | Ruby |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
[x*x for x in arr if x > 25] | [x*x for x in arr if x > 25] | Correct list comprehension. | Python |
<br></br> | <br> | Self-closing. | HTML |
let data = 75; let data = 60; | let data = 75; data = 60; | Duplicate declaration. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
data[51] | if (data.indices.contains(51)) data[51] | Check index. | Kotlin |
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 |
if [ $z = 44 ]; then | if [ "$z" = 44 ]; then | Quote variable. | Shell |
if (x = 45) {{}} | if (x == 45) {{}} | Use ==. | Java |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
if (val = 73) {{}} | if (val === 73) {{}} | Use === for equality. | JavaScript |
List(27,10,5) | List(27,10,5) | Correct. | Scala |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:46}}; | Add missing property. | TypeScript |
80c = 10 | c80 = 10 | Variable cannot start with digit. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
re.sqrt(6) | import re
re.sqrt(6) | Import module first. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
if (bar = 87) {} | if (bar == 87) {} | Use ==. | Dart |
[93, 46, 22 | [93, 46, 22] | Close bracket. | Ruby |
if val > 19
print('message') | if val > 19:
print('message') | Colon missing after if. | Python |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val foo = 58; foo = 65 | var foo = 58; foo = 65 | Use var for reassignment. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
jwt.sign({{id:85}}, 'key'); | jwt.sign({{id:85}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
x := 55 | x := 55 | Correct. | Go |
$data[27] | if ($data.Count -gt 27) {{ $data[27] }} | Check bounds. | PowerShell |
class Person {{ int y; }}
obj.y=5; | class Person {{ public int y; }}
obj.y=5; | Make field public. | Java |
my @arr = (55,49,28); | my @arr = (55,49,28); | Correct. | Perl |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
list.forEach(function(data) {{ console.log(data); }}) | list.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if result = 57 {{}} | if result == 57 {{}} | Use ==. | Swift |
values(20) | if length(values) >= 20, values(20), end | Check length. | MATLAB |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for temp in range(36)
print(temp) | for temp in range(36):
print(temp) | Colon after for. | Python |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
{{'id':44, 'name' 65}} | {{'id':44, 'name':65}} | Colon missing. | Python |
name: hello
age: 99 | name: hello
age: 99 | Correct. | YAML |
var z int = 'value' | var z string = 'value' | Type mismatch. | Go |
def handle(x):
return x + 1 | def handle(x):
return x + 1 | Correct. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<person age=3> | <person age="3"> | Quote attribute. | XML |
x > 93 & z < 51 | x > 93 and z < 51 | Use 'and' not '&'. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let foo = 28; | let foo = 28; | Correct. | JavaScript |
'hello' + 54 | 'hello' + 54.to_s | Convert int. | Ruby |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(60); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(60); | Correct. | Node.js |
let str = String::from("data"); let r=&str; str.push_str("!"); | let mut str = String::from("data"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
h1 {{ font-size:52px color:blue; }} | h1 {{ font-size:52px; color:blue; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.